<template>
  <div class="icons-container">
    <div v-for="item of svgIcons" :key="item" @click="select(item)">
      <el-tooltip placement="top">
        <div slot="content">{{ generateIconCode(item) }}</div>
        <div class="icon-item">
          <svg-icon :icon-class="item" class-name="disabled"/>
          <span>{{ item }}</span>
        </div>
      </el-tooltip>
    </div>
  </div>
</template>

<script>
import svgIcons from './svg-icons';
import elementIcons from './element-icons';

export default {
  name: 'Icons',
  data() {
    return {
      svgIcons,
      elementIcons
    };
  },
  methods: {
    generateIconCode(symbol) {
      return `<svg-icon icon-class="${symbol}" />`;
    },
    select(text) {
      this.$emit('select', text);
    }
  }
};
</script>

<style lang="scss" scoped>
.icons-container {
  margin: 10px 20px 0;
  overflow: hidden;

  .icon-item {
    margin: 20px;
    height: 85px;
    text-align: center;
    width: 100px;
    float: left;
    font-size: 30px;
    color: #24292e;
    cursor: pointer;
  }

  span {
    display: block;
    font-size: 16px;
    margin-top: 10px;
  }

  .disabled {
    pointer-events: none;
  }
}
</style>
